import { Vec2 } from "./Vec2";

/**
 * a*结点
 */
export abstract class AStarNode {
    /**坐标位置 */
    readonly pos: Vec2;
    /**父结点 */
    parent: AStarNode | null;
    /**实际成本 */
    G: number;
    /**估计成本 */
    H: number;
    /**总成本 */
    get F(): number {
        return this.G + this.H;
    }

    constructor(pos: Vec2, parent: AStarNode | null, G: number, H: number) {
        this.pos = pos;
        this.parent = parent;
        this.G = G;
        this.H = H;
    }

    /**
     * 判断两个结点是否相等
     */
    abstract equal(node: AStarNode): boolean;

    /**获得两点间的实际距离 */
    abstract realDistance(node: AStarNode): number;
}